-
Notifications
You must be signed in to change notification settings - Fork 112
Carbon Type Descriptors via ReflectionDescriptor #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Carbon Type Descriptors via ReflectionDescriptor #192
Conversation
|
@ondrejmirtes hello! Firstly, thank you for this extension and PHPStan in general, it's very useful! 👍 I'm looking to add type descriptors for Carbon date types and wanted to check two things first:
|
|
Hi, can you link to those Carbon Doctrine types you want to describe? Thanks. As for your installation problem:
Check out the CI scripts, it's not doing anything special... |
Hey, thanks for the fast reply. I managed to run the installation with Regarding the types, here they are: They both use the CarbonTypeConverter to do the conversions from/to database. |
|
The easiest way forward would be for the library to add proper typehints - the methods convertToPHPValue and convertToDatabaseValue don't have the correct return typehints. And after that registering the ReflectionDescriptor would be sufficient. (https://github.com/phpstan/phpstan-doctrine#reflectiondescriptor). Alternatively an implementation like https://github.com/phpstan/phpstan-doctrine/blob/master/src/Type/Doctrine/Descriptors/Ramsey/UuidTypeDescriptor.php would also work. |
|
Thanks for the details. Looks like not even the Doctrine date types have those type hints 🤷♂️ . Also it might be difficult due to the way the code is structured as the converter is used for both Carbon and CarbonImmutable. The return type of The above is mostly why I thought a custom descriptor like DateTimeImmutableType would be the easiest, unless I'm missing something. |
|
Oh, in that case we need a custom DoctrineTypeDescriptor implementation here :) So please submit the PR, thanks :) |
Added now, please run the workflow as it's my first time contributing here :) |
3f98b48 to
1e3c1ea
Compare
|
@ondrejmirtes hey 👋 , this is updated and ready for re-review now |
|
thank you! 💯 |
Description
This PR adds type descriptors for Carbon date types Carbon and CarbonImmutable using the ReflectionDescriptor.
Made possible after: briannesbitt/Carbon#2344.
Features / Changes
extension.neonMyBrokenEntity.php